<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <img src="./imgs/1t.png" />
    <button>点击我切换图片</button>
    <script>
        var btn = document.querySelector("button");
        var img = document.querySelector("img");
        btn.onclick = function(){
            img.style.transition = "all 1s";
            img.style.opacity = 0;
            img.ontransitionend = function(){
                console.log("过渡结束");
                img.src = "./imgs/2t.png";
                img.style.opacity = 1;
            }

            // 
        }

    </script>
</body>
</html>